
//
//  LSTabBarViewController.m
//  HaoShiHuo
//
//  Created by apple on 14-4-17.
//  Copyright (c) 2014年 paris. All rights reserved.
//


#import "LSTabBarViewController.h"
@interface LSTabBarViewController (){

    UIButton *_selectedButton;
    NSArray *_selectImages;
    NSArray *_images;
    LSTabbar *_tabbar;
}

@end

@implementation LSTabBarViewController

@synthesize tabbarView;
@synthesize selectedButton = _selectedButton;


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
     self.tabBar.hidden = YES;
    if (!tabbarView) {
        
        [self initButtons];
    }
    
}

//龙波手表

- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
}

- (void)clickCenter:(UIButton *)sender
{
   
}
- (void)changeSeleted:(NSNotification *)noti
{
    NSInteger integer = [[noti object]integerValue];
    UIButton *sender = (UIButton *)[tabbarView.backView viewWithTag:integer+9320];
    [self clickSeg:sender];
}
- (void)clickSeg:(UIButton *)sender
{
    
    if (sender.selected) return;
    
    for (UIButton *cen in tabbarView.bottomButtons) {
        cen.selected = NO;
        cen.userInteractionEnabled = YES;
    }
    
    self.tabBar.hidden=NO;
    
    self.selectedButton = (UIButton *)[tabbarView.backView viewWithTag:sender.tag];
    self.selectedButton.selected = YES;
    self.selectedButton.userInteractionEnabled = NO;
    NSInteger sen = sender.tag;
    self.selectedIndex = sen-9320;
}
- (void)initButtons{

    tabbarView = [[LSTabbar alloc]initWithMainTabbar:CGRectMake(0,0, __MainScreen_Width, 71) block:^(UIButton *sender) {
        [self clickSeg:sender];
    }];
    //这里面也可以设置Tabbar的初始位置
    self.selectedButton = (UIButton *)[tabbarView.backView viewWithTag:9320];
    self.selectedButton.selected = YES;
    self.selectedButton.userInteractionEnabled = NO;
    [tabbarView setFrame:CGRectMake(0,[[UIScreen mainScreen]bounds ].size.height-71,__MainScreen_Width, 71)];
  
    
    
    UINavigationController *nav = (UINavigationController *)self.selectedViewController;
   
    if (nav.childViewControllers.count<=1) {
        [self.view addSubview:tabbarView];
        [self.view bringSubviewToFront:tabbarView];
    }
    
}




- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    return NO;
}






- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
